function [bit, bit_e]=processing(streams,stream_LEN,TH,T_matr,P)
number_streams=length(stream_LEN);
bit=0;
bit_e=0;
for i=1:number_streams
    data=streams(i,1:stream_LEN(i)); %choose stream
    AD=abs(data); %absolute values
    F=find(data~=0); %find number of signs
    sS=data(F); %sequence of nonzeros 
    N=length(sS); %number of signs
    SS=double(sS>0); % binary sequence of signs
    b_signs=stat_krich_speed(SS,2);
    disp('bits for signs: number nonzeros, krich');
    disp([N b_signs]);
   % disp('entropy of signs');
    %disp(entropm(SS));
    %pause
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    Ma_data=max(AD);
    Mi_data=min(AD);
    Alphabet_data=Ma_data-Mi_data+1;
    b_kr=stat_krich_speed(AD,Alphabet_data);
    %b_kr=entrop_alg_K(AD,Alphabet_data)
    b_A=stat_arith_A(AD,Alphabet_data);
    %b_A=entrop_alg_A(AD,Alphabet_data)
    %%%%%Logarithming%%%%%%%
    [b_data,add_data]=logarithmir(AD,TH);%bit categories and add bits
    Ma_l=max(b_data);
    Mi_l=min(b_data);
    Alphabet_l=Ma_l-Mi_l+1;
    b_l=stat_krich_speed(b_data,Alphabet_l);
    b_A_l=stat_arith_A(b_data,Alphabet_l);
    %%%%%%%%%%%%%%%Escape%%%%%%%%%%%%%%%
    r=escape(AD,T_matr);
    %r=escape_data(AD,T_matr)
    b_r=stat_krich_speed(r,T_matr+1);
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Golomb%%%
    b_g=sum(golomb(AD,P));
    disp('bits for abs values: krich, krich+logarith, escape+krich, golomb, A, logarith+A ');
    disp([b_kr b_l+add_data b_r b_g b_A b_A_l+add_data]);
    %disp('entropy of abs values');
    %disp(entropm(AD));
   % pause;
    bit=bit+min([b_kr b_l+add_data b_r b_g  b_A b_A_l+add_data])+min([N b_signs]);
    bit_e=bit_e+entropm(SS)+entropm(AD);
   % pause
end;    
    
   